package edu.pku.sei.transformation.editor.controller.commands.node;

import org.eclipse.gef.commands.Command;

import edu.pku.sei.transformation.editor.model.execution.Pin;
import edu.pku.sei.transformation.editor.model.execution.TransformationExecution;

public class PinDeleteCommand extends Command {
	private Pin p;
	private TransformationExecution te;

	public PinDeleteCommand(Pin p, TransformationExecution te) {
		this.p = p;
		this.te = te;
	}

	@Override
	public boolean canExecute() {
		if (p == null || te == null)
			return false;
		return true;
	}

	@Override
	public void execute() {
		p.setExecution(null);
		te.getActualParameters().remove(p);
	}

	@Override
	public void undo() {
		p.setExecution(te);
		te.getActualParameters().add(p);
	}
}
